home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1210 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: mailhost.mwmicro.com!news
  2. From: aschlies@citynet.net (Tony Schliesser)
  3. Newsgroups: comp.lang.c
  4. Subject: returning a string from a function
  5. Date: Fri, 12 Jan 1996 05:01:53 GMT
  6. Organization: MidWest Micro
  7. Message-ID: <4d4uh8$q46@mailhost.mwmicro.com>
  8. Reply-To: aschlies@citynet.net
  9. NNTP-Posting-Host: pd011.mwmicro.com
  10. X-Newsreader: Forte Agent .99c/32.126
  11.  
  12. I am learning C with the aid of only a book.  I am at an inpass in
  13. this process.  I have a small function that needs to return a string
  14. back to the main routine. I have the following prototype:
  15.  
  16. char function_name(char in_string[80])
  17.  
  18. {
  19.     char value[80];
  20.  
  21.     ...value takes on part of the value of the last 10 characters
  22.       of in_string.
  23.  
  24.     return(value);
  25. }
  26.  
  27.  
  28. jWhen this function is done, it only returns the first character.  I
  29. "watched" the program execution and it shows that value indeed has the
  30. last 10 characters.  Any clues as to why the calling routine only gets
  31. the one character??
  32.  
  33. Also, I wrote the routine that copies the last 10 characters. Is there
  34. a lib. function that does that for me?? Did I reinvent the wheel?
  35.  
  36. Thanks for your patients.
  37.  
  38. Tony
  39.  
  40.